﻿using System;
using System.Collections.Generic;
using System.Text;
using ORMapping;
using NHibernate;

namespace DAL
{
    public class CardHistoryDAL
    {
        private EntityControl<CardHistory> control;
        
        public CardHistoryDAL()
        {
            control = EntityControl<CardHistory>.CreateEntityControl("ORMapping");
        }

        public Int32 AddCardHistory(CardHistory cardhistory)
        {
            return Convert.ToInt32(control.AddEntity(cardhistory));
        }

        public long CardCount()
        {
            return control.Count();
        }

        public IList<CardHistory> GetCardHistoryByCardId(Int32 CardID)
        {
            string strHQL = "from CardHistory c where c.CardID.CardID = :CardID order by c.CardIDHistory";
            System.Collections.Generic.List<HQLParameter> hp = new System.Collections.Generic.List<HQLParameter>(1);
            hp.Add(new HQLParameter(EnumHQLParameterType.INT32, "CardID", CardID));
            IList<CardHistory> lc = control.GetEntities(strHQL, hp);
            return lc.Count > 0 ? lc : null;
        }
    }
}
